<extend name="Common@Common:layui_cdn" />
<block name="title">
    <title>编辑</title>
</block>

<block name="main">
    <div id="infoform">
        <form class="layui-form close-dialog" style="padding:20px;" onsubmit="return false;" action="/api/content/edit_post" method="post">

            <div class="layui-form-item">
                <label class="layui-form-label">父节点：</label>
                <div class="layui-input-inline">
                    <select name="parentid">
                        <option value="0" <if condition="$info['parentid'] eq 0">selected</if>>根节点</option>
                        {$select_categorys}
                    </select>

                </div>
                <if condition="$info['id']">
                    <span style="line-height:38px;color:red">当前菜单ID：<b>{$info.id}</b></span>
                </if>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">文章名：</label>
                <div class="layui-input-inline">
                    <input type="text" name="title" value="{$info.title}" id="title" required="" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">key：</label>
                <div class="layui-input-inline">
                    <input type="text" name="key" value="{$info.key}" id="key" required="" lay-verify="required|key" placeholder="key值为唯一" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否启用：</label>
                <div class="layui-input-inline">
                    <php>
                        if($info['status'] == ''){ $info['status'] = 1; }
                    </php>
                    <input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="启用|禁用" <if condition="$info['status'] eq 1">checked</if> >
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="id" id="id" value="{$_REQUEST['id']}">
                    <button class="layui-btn" lay-submit="" lay-filter="*">确定</button>
                </div>
            </div>
        </form>
    </div>
</block>

<block name="script">
    <script>
        layui.use(['jquery', 'form'], function() {
            $ = layui.jquery,
                form = layui.form;

            form.verify({
                key: function(value) {
                    if (value) {
                        if (/^[a-zA-Z]+$/.test(value)) {
                            return;
                        } else {
                            return '只能输入字母！';
                        }
                    }
                }
            });
        });
    </script>
</block>